<!-- 页面设计已注册版权，部分或全部盗用，一经发现将由【正途知识产权代理（上海）有限公司】律师团队依法维权，特此公告； -->
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>邀请礼核销</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
  <link rel="stylesheet" type="text/css" href="{$_G['URL']['HEXIAO_CSS']}css/reset.css">
  <link rel="stylesheet" type="text/css" href="{$_G['URL']['HEXIAO_CSS']}css/swiper.min.css">
  <link rel="stylesheet" type="text/css" href="{$_G['URL']['HEXIAO_CSS']}css/style.css?v=1">
  <script src="{$_G['URL']['YX2020_CSS']}js/md5.js?v=2"></script>
  <script type="text/javascript" src="{$_G['URL']['PUBLIC_JS']}yx2020/ping.js?v=15"></script>
  <script src="{$_G['URL']['HEXIAO_CSS']}js/jquery.js"></script>
  <script src="{$_G['URL']['LOTTERY_CSS']}lottery/js/layer/layer.js"></script>
  <style type="text/css">
    .topBox img { border-radius: 30px;}
  </style>
</head>
<body>

<div class="topBox" style="min-height: 1.47rem">
  <div class="orderTit">
    <img src="{$_G['URL']['HEXIAO_CSS']}images/order.png">
    核销礼品信息
  </div>
  <ul>
    <li style="height: 40px;font-size: 20px;width: 100vw;color: #ffffff;">{$shop_item['name']}</li>
  </ul>
</div>
<div class="userBox">
  <div class="userTop">
    <div class="userImg"><img src="{$fans['avatar']}"></div>
    <div class="userInfor">
      <h2>{$fans['nickname']}</h2>
      <p><span><img src="{$_G['URL']['HEXIAO_CSS']}images/icon5.png">{$fans['username']}</span><span><img src="{$_G['URL']['HEXIAO_CSS']}images/icon6.png">{$fans['mobile']}</span></p>
    </div>
  </div>
</div>
<style>
  .hexiao{
    display: flex;
    height:31px;
    line-height:31px;
    margin-bottom:unset;
    width: 80px;
    justify-content: center;
    font-size:13px;
  }
  .yi{
    background: #c3c3c3;
    border-radius: 20px;
  }
  .qv{
    color: #ffffff;
    border-radius: 20px 0px 0px 20px;
    background: linear-gradient(to right,#ff767f,#fe4551);
  }
  .div1{
    height:41px;line-height:41px;align-items:center;width: 87vw;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
  }
  .div2{
    width: 87vw;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    color: #8d939c;
  }
  .name{
    font-size:16px;
    font-weight:bold;
  }
</style>
{loop $list $row}

<div class="cost" >
  <div class="div1">
    <div class="name">{$row['name']}</div>
    {if $row['status']==2}
    <div class="hexiao yi">已核销</div>
    {else}
    <div class="hexiao qv"  data-gift_recordid="{$row['id']}" onclick="verifyOnly(this)">去核销</div>
    {/if}
  </div>
  <div class="div2" >
    <p>{$row['tiaojian']}</p>
    <p> {$row['workername']}</p>
    <p style="text-align: right;">
      {if $row['status']==2}
        {$row['exchange_at']}
      {else}
        {$row['created_at']}
      {/if}
    </p>
  </div>
</div>


{/loop}
{if $gift_config["exchange_mode"]==2}
<div class="fixButton">
  <a href="javascript:void(0);" style="	float: left;width: 140px;height: 45px;background:#5aa2fc;line-height: 45px;border-radius: 0 45px 45px 0;background-size: 17px;text-indent: 33px;font-size: 15px;color: #fff; " onclick="verifyAll(this)">全部核销</a>
</div>
{/if}

</body>
<script>
  var uid='{$list[0]["uid"]}';
  var gift_recordids='{$gift_recordids}';
  var exchange_mode='{$gift_config["exchange_mode"]}';
  //全选核销
  function verifyAll() {
    let postUrl = '/{php echo createMobileUrl("wx",array("themeid"=>$themeid,"from"=>"mobile","r"=>"gift.index.is_verified","verify_type"=>"all"));}';
    ajaxpost(postUrl, {gift_recordid: gift_recordids,gift_record_uid:uid});
  }

  //单选核销
  function verifyOnly(e) {
    var gift_recordid = e.getAttribute("data-gift_recordid");
    let postUrl = '/{php echo createMobileUrl("wx",array("themeid"=>$themeid,"r"=>"gift.index.is_verified","verify_type"=>"only"));}';
    let data = {gift_recordid: gift_recordid, gift_record_uid:uid};
    if(exchange_mode==1) {
      layer.confirm('当前模式只能核销一项礼品！是否核销该礼品？', {
        btn: ['确认']
      }, function (index) {
          ajaxpost(postUrl,data);
      });
    }else{
      ajaxpost(postUrl,data);
    }

  }

  function ajaxpost(url,array){
    let postUrl = url;
    let data = array;
    $.ajax({
      type: 'POST',
      data: data,
      dataType: "json",
      url: postUrl,
      success: function (res) {
        layer.msg(res.msg);
        setTimeout(function () {
          location.reload();
        }, 1000);
      }
    });
  }


</script>
</html>
